# 3.36 WiFi Control ## 3.36.1 Overview We control LED, servo and the fan on the web page button wirelessly. ## 3.36.2 Test Code ### 3.36.2.1 Build Code There are two ways to upload the code: directly open the code file we provide; or manually build blocks. **Directly open the code file we provide:** 1. Click ![](./media/j68.png) and choose `Load from your computer` ![](./media/j67.png) 2. We have already downloaded the codes on computer desktop, so open the file and choose `3-36-wifiWebpageControl.sb3` **Manually build blocks:** 1. Initialize wifi and OLED, display the IP address of the wifi on the OLED. Name a variable used to switch sensor state according to the corresponding functions, for example, we name redLed to represent the red led. ![QQ_1722234105165](./media/6-36-2-1-1.png) 2. Set web buttons and add functions of buttons by block ![QQ_1722222062997](./media/j66.png); Add ![j16](./media/j16.png) to determine whether the value = 0. If yes, execute code in “then”. If not, run code in “else”. We take red led as an example. Initially, redLed = 0. When the red led button is pressed, the red led will light up and redLed becomes 1. When you press this button next time, code in “else” will be execute, so the led goes off and redLed = 0 again. ![QQ_1722234332241](./media/6-36-2-1-2.png) 3. Similarly, set blocks of yellow led, green led, Servo and motor. **Complete Test Code** ![6-36-2-1](./media/6-36-2-1.png) ### 3.36.2.2 Test Result Upload the code, and the OLED shows the IP address after connecting to wifi. Connect your computer/mobile phone and ESP32 to the same wifi, and you can access the IP address to see the control page through your device. ![](./media/6-36-2-2.png)